global.__projectDir = __dirname;

var http         = require('http');
var express      = require('express');        // call express
var expressWs    = require('express-ws');
var SENDMSG = require('./lib/SendMsg');
var bodyParser = require('body-parser');
var cookieParser = require('cookie-parser');
var path = require('path');



var conf = require('./config');
var httpPort  = conf.ports.httpPort;

var app = express();

app.engine('.hbs', require('hbs').__express)
app.set('views', __dirname + '/public/views');
app.set('view engine', 'hbs');

// ---启动http server
var Server = http.createServer(app);
Server.listen(httpPort, function() {
    console.log((new Date()) + ' GjjAPI start http server and listen on: ' + JSON.stringify(Server.address()));
    //SENDMSG('15267034337','[GJJAPI] 服务重启 '+new Date());
});
expressWs(app, Server);

// 给app配置bodyParser中间件
// 通过如下配置再路由种处理request时，可以直接获得post请求的body部分
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

var wld = require('./routes/gdBank/index');
var ws = require('./routes/gdBank/ws');

 app.use('/',wld);
 app.use('/ws',ws);

 

